package com.hnl.core;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;

import com.hnl.util.XMLConfigUtil;

public class DataConfig {
	static final Logger LOG = LoggerFactory.getLogger(DataConfig.class);

	public Map<String, Properties> dataSources = new HashMap<String, Properties>();

	public void readDataSourcesFromXml(Element e) {
		List<Element> n = XMLConfigUtil.getChildNodes(e, HNLConfig.DATA_SRC);
		if (!n.isEmpty()) {
			for (Element element : n) {
				Properties p = new Properties();
				HashMap<String, String> attrs = XMLConfigUtil
						.getAllAttributes(element);
				for (Map.Entry<String, String> entry : attrs.entrySet()) {
					p.setProperty(entry.getKey(), entry.getValue());
				}
				dataSources.put(p.getProperty("name"), p);
			}
		}
	}

}
